<template>
  <div class="total-container">
    <div class="left-container"></div>
    <div class="right-container">
      <div class="item-box" v-for="item in data" :key="item.name">
        <div class="title">{{ item.name }}</div>
        <div class="value">
          <div class="num">
            <countTo :startVal="0" :endVal="item.num" :duration="1200" separator=""></countTo>
          </div>
          <div class="unit">{{ item.unit }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { zrdl } from '@/api/dongyingData'
import countTo from 'vue-count-to'
export default {
  name: 'naturalResources',
  data() {
    return {
      data: [
        {
          name: '地下水可供利用水资源',
          num: 0,
          unit: '亿立方米'
        },
        {
          name: '境内野生脊椎动物',
          num: 0,
          unit: '种'
        },
        {
          name: '境内野生植物',
          num: 0,
          unit: '种'
        },
        {
          name: '矿产资源',
          num: 0,
          unit: '种'
        }
      ]
    }
  },
  components: {
    countTo
  },
  mounted() {
    this.getData()
  },
  methods: {
    async getData() {
      const res = await zrdl.zrzy()
      this.data[0].num = res.result[0].dxsklyszy
      this.data[1].num = res.result[0].jnysjzdw
      this.data[2].num = res.result[0].jnysjzdw
      this.data[3].num = res.result[0].kczy
    }
  }
}
</script>
<style lang="scss" scoped>
.total-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .left-container {
    width: 58px;
    height: 198px;
    background-image: url('../../../img/left-row1-icon1.png'),
      url('../../../img/left-row1-icon2.png');
    background-repeat: no-repeat, no-repeat;
    background-position: center center, center left;
    background-size: 100% 100%, 37px 37px;
  }
  .right-container {
    height: 198px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    .item-box {
      height: 32px;
      width: 357px;
      background: url('../../../img/left-row1-icon3.png') no-repeat center
        center;
      background-size: 100% 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-left: 10px;
      padding-right: 30px;
      .title {
        font-family: MicrosoftYaHeiUI;
        font-size: 16px;
        color: #ffffff;
        line-height: 16px;
        text-align: left;
        font-style: normal;
        text-transform: none;
      }
      .value {
        display: flex;
        justify-content: end;
        align-items: baseline;
      }
      .num {
        font-family: YouSheBiaoTiHei;
        font-size: 24px;
        color: #ffdd00;
        line-height: 24px;
        text-align: right;
        font-style: normal;
        text-transform: none;
      }
      .unit {
        font-family: MicrosoftYaHeiUI;
        font-size: 14px;
        color: #d9e8f4;
        line-height: 14px;
        text-align: left;
        font-style: normal;
        text-transform: none;
        margin-left: 3px;
      }
    }
  }
}
</style>
